package physics;

public class Rectangle extends Shape{
	Vector botLeftPosn;
	Vector topRightPosn;
	
	public Rectangle(Vector center, double width, double height, 
			Vector vel, boolean isFixed) {
		this.botLeftPosn = new Vector(center.x - (width/2), center.y - (height/2));
		this.topRightPosn = new Vector(center.x + (width/2), center.y + (height/2));
		this.vel = vel;
		this.acc = nullVec;
		this.gravity = 0;
		this.fixed = isFixed;
		if(isFixed) {
			this.mass=500000000;
		} else {
			this.mass = 1;
		}
	}
	
	public Rectangle(Vector center, double width, double height, 
			Vector vel, double gravity, double mass, boolean isFixed) {
		this.botLeftPosn = new Vector(center.x - (width/2), center.y - (height/2));
		this.topRightPosn = new Vector(center.x + (width/2), center.y + (height/2));
		this.vel = vel;
		this.acc = nullVec;
		this.gravity = gravity;
		this.mass = mass;
		this.fixed = isFixed;
		if(isFixed) {
			this.mass=500000000;
		} else {
			this.mass = 1;
		}
	}
	
	public Rectangle(Vector botLeft, Vector topRight) {
		this.botLeftPosn = botLeft;
		this.topRightPosn = topRight;
		this.posn = new Vector(botLeft.x + (topRight.x - botLeft.x)/2, 
				botLeft.y + (topRight.y - botLeft.y)/2);
		this.vel = nullVec;
		this.acc = nullVec;
		this.mass = 1;
		this.gravity = 0;
		this.fixed = false;
	}
	
	public Rectangle(Vector botLeft, Vector topRight, boolean isFixed) {
		this.botLeftPosn = botLeft;
		this.topRightPosn = topRight;
		this.posn = new Vector(botLeft.x + (topRight.x - botLeft.x)/2, 
				botLeft.y + (topRight.y - botLeft.y)/2);
		this.vel = nullVec;
		this.acc = nullVec;
		this.gravity = 0;
		this.fixed = isFixed;
		if(isFixed) {
			this.mass = 500000000;
		} else {
			this.mass = 1;
		}
	}
	
	public Rectangle(Vector botLeft, Vector topRight, Vector vel) {
		this.botLeftPosn = botLeft;
		this.topRightPosn = topRight;
		this.posn = new Vector(botLeft.x + (topRight.x - botLeft.x)/2, 
				botLeft.y + (topRight.y - botLeft.y)/2);
		this.vel = vel;
		this.acc = nullVec;
		this.gravity = 0;
		this.fixed = false;
	}
	
	public Rectangle(Vector botLeft, Vector topRight, Vector vel, Vector acc) {
		this.botLeftPosn = botLeft;
		this.topRightPosn = topRight;
		this.posn = new Vector(botLeft.x + (topRight.x - botLeft.x)/2, 
				botLeft.y + (topRight.y - botLeft.y)/2);
		this.vel = vel;
		this.acc = acc;
		this.gravity = 0;
		this.fixed = false;
	}
	
	public Rectangle(Vector botLeft, Vector topRight, Vector vel, Vector acc, 
			double grav, boolean fixed) {
		this.botLeftPosn = botLeft;
		this.topRightPosn = topRight;
		this.posn = new Vector(botLeft.x + (topRight.x - botLeft.x)/2, 
				botLeft.y + (topRight.y - botLeft.y)/2);
		this.vel = vel;
		this.acc = acc;
		this.gravity = grav;
		this.fixed = fixed;
	}
	
	public Vector getPosn() {
		return posn;
	}
	
	public void changePosn(Vector offset) {
		this.posn = this.posn.add(offset);
		this.botLeftPosn = this.botLeftPosn.add(offset);
		this.topRightPosn = this.topRightPosn.add(offset);
	}
	
	public double getWidth() {
		return topRightPosn.getX() - botLeftPosn.getX();
	}

	public double getHeight() {
		return topRightPosn.getY() - botLeftPosn.getY();
	}

	public Vector getBotLeftPosn() {
		return botLeftPosn;
	}

	public void setBotLeftPosn(Vector botLeftPoint) {
		this.botLeftPosn = botLeftPoint;
	}

	public Vector getTopRightPosn() {
		return topRightPosn;
	}

	public void setTopRightPosn(Vector topRightPoint) {
		this.topRightPosn = topRightPoint;
	}
	
}
